//
//  BaseMode.swift
//  GeneralNetworkTool
//
//  Created by Jin on 25/05/2018.
//  Copyright © 2018 Jin. All rights reserved.
//

import Foundation

class BaseModel: Codable {
    var requestParam:BaseRequestHeader?
    
    internal func encode(to encoder:Encoder) throws {
        var container = encoder.container(keyedBy: BaseModel.CodingKeys.self)
        try container.encodeIfPresent(requestParam, forKey: .requestParam)
    }
}

class BaseHeaderModel: Codable {
    var requestCode:String?
    var sessionId:String? = "1"
    var terminalType:String?
    
    private enum CodingKeys:String,CodingKey {
        case requestCode
        case sessionId
        case terminalType
    }
    
    internal func encode(to encoder:Encoder) throws {
        var container = encoder.container(keyedBy: CodingKeys.self)
        try container.encodeIfPresent(requestCode, forKey: .requestCode)
        try container.encodeIfPresent(sessionId, forKey: .sessionId)
        try container.encodeIfPresent(terminalType, forKey: .terminalType)
    }

}
